/**
 * 
 * @author Marina Polese
 *
 */

package capture;

public class Filter {
	private String paramIP;
	private String ip;
	private String paramPort;
	private String port;
	private String protocol;
	
	public String getParamIP() {
		return paramIP;
	}
	
	public void setParamIP(String paramIP) {
		this.paramIP = paramIP;
	}
	
	public String getIp() {
		return ip;
	}
	
	public void setIp(String ip) {
		this.ip = ip;
	}
	
	public String getParamPort() {
		return paramPort;
	}
	
	public void setParamPort(String paramPort) {
		this.paramPort = paramPort;
	}
	
	public String getPort() {
		return port;
	}
	
	public void setPort(String port) {
		this.port = port;
	}
	
	public String getProtocol() {
		return protocol;
	}
	
	public void setProtocol(String protocol) {
		this.protocol = protocol;
	}
	
	public String toString(){
		String filter = "";
		if(ip!=null && ip.length()>0){
			filter = paramIP!=null ? paramIP + " host " + ip : "host "+ ip;
		}
		if(port!=null && port.length()>0){
			if(filter.length()>0){
				filter = filter + " and " + port;
			} else{
				filter = port;
			}
			if(paramPort!=null){
				filter = filter.replace("port", paramPort + " port");
			}
		}
		if(protocol!=null && protocol.length()>0){
			if(filter.length()>0){
				filter = filter + " and " + protocol;
			} else{
				filter = protocol;
			}
		}
		return filter;
	}
	
	

}
